import { MountBaseRenderer } from "./MountBaseRenderer";
import { IDragDrop } from "../../../../../com/mui/manager/IDragDrop";
import { ItemData } from "../../../resource/info/ItemData";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
//class MountItemRenderer
    
    export  class MountItemRenderer extends MountBaseRenderer implements IDragDrop
    {
        constructor()
        {
            super();
            this.addEventListener(flash.events.MouseEvent.MOUSE_DOWN, this.onMouseDown);
            this.addEventListener(flash.events.MouseEvent.CLICK, this.onClickHander);
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            this._itemData = _data as ItemData;
            if (this._itemData) 
            {
                isLock = false;
                load(this._itemData.itemInfo.item.icon + ".jpg");
                this.buttonMode = true;
                this.mouseChildren = true;
                toolTipData = this._itemData.getToolTipData(ItemData.ToolTipType_Mounts);
            }
            else 
            {
                this.buttonMode = false;
                this.mouseChildren = false;
                toolTipData = null;
            }
            return;
        }

        public /* override */ get data(): Object
        {
            return this._data;
        }

        public get dragSource(): Object
        {
            return this._data;
        }

        public set dragSource(arg1: Object)
        {
            return;
        }

        public get isDragAble(): Boolean
        {
            return this._dragAble;
        }

        public set isDragAble(arg1: Boolean)
        {
            this._dragAble = arg1;
            if (this._dragAble) 
            {
                this.addEventListener(flash.events.MouseEvent.MOUSE_DOWN, this.onMouseDown);
            }
            else if (this.hasEventListener(flash.events.MouseEvent.MOUSE_DOWN)) 
            {
                this.removeEventListener(flash.events.MouseEvent.MOUSE_DOWN, this.onMouseDown);
            }
            return;
        }

        public get isDropAble(): Boolean
        {
            return this._dropAble;
        }

        public set isDropAble(arg1: Boolean)
        {
            this._dropAble = arg1;
            return;
        }

        public get isThrowAble(): Boolean
        {
            return false;
        }

        public canDrop(arg1: IDragDrop, arg2: IDragDrop): Boolean
        {
            if (this.dropChecktFunction != null) 
            {
                return this.dropChecktFunction(arg1, this);
            }
            return this.isDropAble;
        }

        protected onMouseDown(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (!(this._itemData && this.isDragAble)) 
            {
            };
            return;
        }

        protected onClickHander(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._itemData && arg1.ctrlKey) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.ChatShowItem, this._itemData));
            }
            return;
        }

        protected /* var */_itemData: ItemData;

        protected /* var */_dragAble: Boolean=true;

        protected /* var */_dropAble: Boolean=true;

        protected /* var */_throwAble: Boolean=true;

        public /* var */dropChecktFunction: Function;
    }
